using System;
using System.Reflection.Emit;
using Pine.Core;
using Pine.SourceParser.Tree;

namespace Pine.CodeGen
{
	public static class BooleanConstantCodeGenerator
	{
		public static void GenerateBytecode(Context ctx, Expression expr, LocalBuilder lb) {
			if (((BooleanConstant) expr).Value)
				ctx.il.Emit(OpCodes.Ldc_I4_1);
			else
				ctx.il.Emit(OpCodes.Ldc_I4_0);
			ctx.il.Emit(OpCodes.Newobj, typeof(BooleanValue).GetConstructor(new Type[] { typeof(bool) }));
			ctx.il.Emit(OpCodes.Stloc, lb);
		}
	}
}

